<?php

namespace App\Http\Controllers\V1;

use App\Http\Controllers\ApiBaseController;
use App\Http\Controllers\Controller;
use App\Models\ProductLimit;
use Illuminate\Http\Request;

class ProductLimitController extends ApiBaseController
{
    //
    public function getList(Request $request)
    {
        $params = $request->all();
        $list = ProductLimit::with(['spec', 'product'])->orderBy('id', 'desc')->paginate($this->pageSize);
        return success(['data' => page_format($list)]);
    }
    public function add(Request $request)
    {
        $params = $request->all();
        $res = ProductLimit::create($params);
        return success();
    }
    public function change(Request $request)
    {
        $params = $request->only(['id', 'limit_time', 'limit_type', 'limit_type_value', 'limit_value', 'remark', 'status']);
        $res = ProductLimit::where('id', $params['id'])->update($params);
        return success();
    }
    public function del(Request $request)
    {
        $id = request('id');
        $res = ProductLimit::destroy($id);
        return  success();
    }
}
